
import request from '@/utils/request'

// 分类管理的请求

// 获取分类列表
export function getCategories(params) {
  return request({
    url: `/categories?_limit=${params._limit}&_start=${params._start}&title_contains=${params.title_contains}`,
    method: 'get'
  })
}

// 新建分类
export function addCategories(data) {
  return request({
    url: '/categories',
    method: 'post',
    data
  })
}

// 编辑分类
export function compileCategories(data) {
  return request({
    url: `/categories/${data.id}`,
    method: 'put',
    data
  })
}

// 获取分类数量
export function categoriesCount(a) {
  let url = ''
  if (a) {
    url = `/categories/count?title_contains=${a}`
  } else {
    url = `/categories/count`
  }
  return request({
    url: url
  // 不写请求，默认是get
  })
}

// 删除分类
export function delCategories(id) {
  return request({
    url: `/categories/${id}`,
    method: 'delete'
  })
}
